<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="formName" required="true"/>
    </cc:interface>
    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <f:view>
            <h:form id="addNewUserForm">
                <p:panel header="#{cc.attrs.formName}" >
                    <h:panelGrid columns="2"> 
                        <h:outputText value="User Name: " />
                        <p:inputText required="true" requiredMessage="Field is required." id="userName" value="#{userManagerBean.name}">
                            <f:ajax event="keyup" render="ajaxmsg" listener="#{userManagerBean.doAjaxCountUserNameLength}" />
                            <f:validateLength minimum="4" maximum="16" />
                        </p:inputText>
                        <h:outputLabel styleClass="infoMsg" id="ajaxmsg" value="#{userManagerBean.userNameLength}" />
                        <h:message styleClass="errorMsg" for="userName" />              

                        <h:outputText value="Password: " />
                        <p:password id="password" value="#{userManagerBean.password}" minLength="6" feedback="true">
                        </p:password>
                        <h:message styleClass="errorMsg" for="password" />
                        <br/>

                        <h:outputText value="Title: " />   
                        <h:selectOneMenu value="#{userManagerBean.title}">  
                            <f:selectItem itemLabel="Mr" itemValue="Mr" />  
                            <f:selectItem itemLabel="Ms" itemValue="Ms" />   
                        </h:selectOneMenu> 

                        <h:outputText value="Frist Name: " />
                        <p:inputText required="true" requiredMessage="Field is required." 
                                     id="firstName" value="#{userManagerBean.firstName}">                     
                        </p:inputText>

                        <h:outputText value="Last Name: " />
                        <p:inputText required="true" requiredMessage="Field is required." 
                                     id="lastName" value="#{userManagerBean.lastName}">                     
                        </p:inputText>
                        
                        <h:outputText value="email: " />
                        <p:inputText required="true" requiredMessage="Field is required." 
                                     id="email" value="#{userManagerBean.email}">                     
                        </p:inputText>
                        
                        <h:outputText value="Address: " />
                        <p:inputText required="false" 
                                     id="address" value="#{userManagerBean.address}">                     
                        </p:inputText>
                        
                        <h:outputText value="Contact Number: " />
                        <p:inputText required="false"  
                                     id="contactNumber" value="#{userManagerBean.contactNumber}">                     
                        </p:inputText>

                        <h:commandButton action="saveNewSystemUser.xhtml" value="Save New User" actionListener="#{userManagerBean.saveSystemUser}" />
                    </h:panelGrid> 
                </p:panel>
            </h:form>
        </f:view>
    </cc:implementation>    
</html>